package com.handsome.迭代器模式;

import java.util.Iterator;

/**
 * @author niechun
 * @date 2023/3/19 13:06
 */
public class ComputerCollegeIterator implements Iterator {
    //以数组的形式存放department;
   private Department[] departments;
   //开始迭代的位置
    private int position=0;

    public ComputerCollegeIterator(Department[] departments) {
        this.departments = departments;
    }

    @Override
    public boolean hasNext() {
        if (position>=departments.length||departments[position]==null){
            return false;
        }
        return true;
    }

    @Override
    public Object next() {
        Department department=departments[position];
        position+=1;
        return department;
    }

    @Override
    public void remove() {

    }
}
